﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Smartec.Accounts.Camel.AMS.Model.Entities;
using Smartec.Accounts.Camel.AMS.Model.Repository;
using Smartec.Accounts.Camel.AMS.Model.Managers;

namespace Smartec.Accounts.Camel.AMS.Model.Facades
{
    public static class PictureFacade
    {
       
        public static Picture GetPicture(int id)
        {
            return PictureRepository.GetPicture(id);
        }

        public static PagedList<Picture> GetPictures(int pageIndex, int pageSize)
        {
            return PictureManager.GetPictures(pageIndex, pageSize);
        }

        public static List<Picture> GetPicturesByAssetId(int assetId)
        {
            return PictureManager.GetPicturesByAssetId(assetId);
        }

        public static List<Picture> GetPicturesByAssetId(int assetId, int recordsToReturn)
        {
            return PictureManager.GetPicturesByAssetId(assetId, recordsToReturn);
        }

        public static string GetDefaultPictureUrl(int targetSize = 0)
        {
            return PictureManager.GetDefaultPictureUrl(targetSize);
        }

        public static byte[] LoadPictureFromFile(int pictureId, string mimeType)
        {
            return PictureManager.LoadPictureFromFile(pictureId, mimeType);
        }

        public static byte[] LoadPictureBinary(Picture picture)
        {
            return PictureManager.LoadPictureBinary(picture);
        }

        public static byte[] LoadPictureBinary(Picture picture, bool fromDb)
        {
            return PictureManager.LoadPictureBinary(picture, fromDb);
        }

        public static string GetPictureUrl(int pictureId, int targetSize = 0, bool showDefaultPicture = true)
        {
            return PictureManager.GetPictureUrl(pictureId, targetSize = 0, showDefaultPicture);
        }

        public static string GetPictureUrl(Picture picture, int targetSize = 0, bool showDefaultPicture = true)
        {
            return PictureManager.GetPictureUrl(picture, targetSize = 0, showDefaultPicture);
        }

        public static string GetPictureLocalPath(Picture picture, int targetSize = 0, bool showDefaultPicture = true)
        {
            return PictureManager.GetPictureLocalPath(picture, targetSize = 0, showDefaultPicture);
        }

        public static byte[] ValidatePicture(byte[] pictureBinary, string mimeType)
        {
            return PictureManager.ValidatePicture(pictureBinary, mimeType);
        }

       
        //
        // Insert/Delete Methods

        public static Picture InsertPicture(byte[] pictureBinary, string mimeType, bool isNew)
        {
            return PictureManager.InsertPicture(pictureBinary, mimeType, isNew);
        }

        public static Picture UpdatePicture(int pictureId, byte[] pictureBinary, string mimeType, bool isNew)
        {
            return PictureManager.UpdatePicture(pictureId, pictureBinary, mimeType, isNew);
        }

        public static void Delete(Picture picture)
        {
            PictureManager.DeletePicture(picture);
        }

        //
        // Persistence 

        public static void Save()
        {
            PictureRepository.Save();
        }

        public static bool StoreInDb
        {
            get
            {
                return PictureManager.StoreInDb;
            }
        }
        // Helper Methods
    }
}

